#include "Player.h"
#include <iostream>

Player::Player(Location l, MyCam &Cam) : 
health(10), 
mana(10), 
loc(l), 
drawMe(true), dead(false), size(1), playerID(0)
{
	fp = fopen ("Player.txt","w");
	TestCam = &Cam;
}

Player::Player(Location l) : 
health(10), 
mana(10), 
loc(l), 
drawMe(true), dead(false), size(1), playerID(0)
{
	fp = fopen ("Player.txt","w");
	// TestCam = &Cam;
}

Player::Player(const Player& p) : 
	health(p.health),
	mana(p.mana),
	loc(p.loc),
	drawMe(true),
	dead(false),
	size(1)
{
	fp = p.fp;
	root = p.root;
}

Player::~Player(void) {
	fclose(fp);
	std::cout << "Deleting Player.\n";
}

SceneRoot* Player::getDrawables(void) {
	return &root;
}

void Player::update(void) {
	/*health--;
	if (health < 1) 
		dead = true;*/
	// Location l = TestCam->getPos();
	
	D3DXVECTOR3 cPos = TestCam->getPos();
	loc.set(cPos.x,cPos.y,cPos.z);
	deleteThis = true;
	// fprintf(fp,"Player %f %f %f | Camera %f %f %f\n",loc.getVal(0),loc.getVal(1),loc.getVal(2),cPos.x,cPos.y,cPos.z);
}

int Player::getSize(void) {
	return size;
}

Location Player::getLocation(void) {
	return loc;
}

bool Player::draw(void) {
	return drawMe;
}

void Player::setDraw(bool d) {
	drawMe = d;
}

bool Player::alive() {
	return !dead;
}

bool Player::canSplit(void) {
	return false;
}

bool Player::deleteMe(void) {
	return deleteThis;
}

std::list<WorldObject *> Player::split() {
	return std::list<WorldObject *>();
}

void Player::setDelete(bool d) {
	deleteThis = d;
}



